package com.wushi.lenovo.asia5b.app_ui.voucher.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mvp.images.WImageLoader;
import com.mvp.utils.ResString;
import com.wushi.lenovo.asia5b.R;
import com.wushi.lenovo.asia5b.app_model.voucher.VoucherModel;

import java.util.List;

/**
 * Created by zhangyuncai on 2019/1/25.
 */
public class SelectVoucherAdapter extends BaseQuickAdapter<VoucherModel, BaseViewHolder> {
    public SelectVoucherAdapter(@Nullable List<VoucherModel> data) {
        super(R.layout.item_selectvoucher_adapter, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, VoucherModel item) {

//图片 iv_voucher_img
        ImageView imageView = helper.getView(R.id.iv_voucher_img);
        WImageLoader.displayImage(mContext, item.getImg_url(), imageView);
        //名称 tv_voucher_name
        helper.setText(R.id.tv_voucher_name, item.getVoucher_name());
        //描述 tv_voucher_desc
        helper.setText(R.id.tv_voucher_desc, item.getDescription());
        String code = String.format(ResString.get(R.string.voucher_code), item.getVoucher_code());
        //code tv_voucher_code
        helper.setText(R.id.tv_voucher_code, code);
        //有效期 tv_voucher_time  2019-02-01 00:00:00  转换 02-01-2019
        helper.setText(R.id.tv_voucher_time, String.format(ResString.get(R.string.valid_till), item.getExpired_date()));
    }
}
